Fix answers disappearing in the hierarchy view when scrolling#7280
Open
grzesiek2010 wants to merge 1 commit into
Open
Fix answers disappearing in the hierarchy view when scrolling#7280grzesiek2010 wants to merge 1 commit into
grzesiek2010 wants to merge 1 commit into
Conversation
seadowg
requested changes
Jun 30, 2026
| // A ComposeView reused from the RecyclerView pool gets measured to 0 height on | ||
| // rebind, so the row renders blank after scrolling. Nudge a remeasure after | ||
| // composition to apply the real height. | ||
| SideEffect { |
Member
There was a problem hiding this comment.
As discussed on Slack, it'd be good to see if we can call requestLayout after setContextThemedContent on ComposeView or just use MutableState hosted in HierarchyListItemView to mutate the content (with only a single call to setContextThemedContent). These options would allow us to avoid SideEffect which can be hard to reason about.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #7275
Why is this the best possible solution? Were any other approaches considered?
The problem was not specific to question types and was not limited to image questions, as suggested in the issue. It was a general issue affecting question answers rendered with Jetpack Compose while being hosted inside a RecyclerView, as we are currently in the process of gradually migrating our UI to Jetpack Compose.
I initially expected this setup to work out of the box, but it appears there are some issues with combining Compose-based views and RecyclerView in this way.
As explained in the comment, the issue was caused by the answer components not being measured correctly: a
ComposeViewreused from the RecyclerView pool keeps a stale, collapsed (0-height) measurement and is never re-measured on rebind, so the row renders blank. Fresh views work because they go through a full measure/layout pass.I considered other approaches such as
ViewCompositionStrategydisposeComposition()on recycle1,2 The first two don't help (the problem is layout-related, not a composition lifecycle issue).
3 Disabling recycling would give up on view recycling entirely.
4 Migrating to LazyColumn should help but that would require way more changes and would be riskier.
Forcing a remeasure after composition keeps recycling intact and is the least invasive fix.
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Question answers in the form hierarchy view no longer disappear after scrolling through a long list. The change is limited to how answer rows in the hierarchy view are laid out, so the regression risk is confined to that screen - mainly the rendering and sizing of answer rows as they are scrolled and recycled.
Do we need any specific form for testing your changes? If so, please attach one.
Any form with many questions, so that the list in the hierarchy is long.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
No.
Before submitting this PR, please make sure you have:
./gradlew connectedAndroidTest(or./gradlew testLab) and confirmed all checks still passDateFormatsTest